package com.qiangqiang.resoldhouse.controller;/*
 *
 */

import com.qiangqiang.resoldhouse.entity.Area;
import com.qiangqiang.resoldhouse.mapper.AreaMapper;
import com.qiangqiang.resoldhouse.service.AreaService;
import com.qiangqiang.resoldhouse.util.ResultVOUtil;
import com.qiangqiang.resoldhouse.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

@RestController
public class AreaController {

    @Autowired
    private AreaService areaService;

    @GetMapping("/findAreaById")
    public ResultVO findAreaById(@RequestParam Integer id){
        return ResultVOUtil.success(areaService.findAreaById(id));
    }

    @GetMapping("/findAllAreas")
    public ResultVO findAllAreas(){
        return ResultVOUtil.success(areaService.findAllArea());
    }

    @GetMapping("/findAreaByName")
    public ResultVO findAreaByName(@RequestParam String name){
        return ResultVOUtil.success(areaService.findAreaByName(name));
    }

    @GetMapping("/deleteAreaById")
    public ResultVO deleteAreaById(@RequestParam Integer id){
        return ResultVOUtil.success(areaService.deleteAreaById(id));
    }

    @PostMapping("/insertArea")
    public ResultVO insertArea(Area area){
        return ResultVOUtil.success(areaService.insertArea(area));
    }

    @PostMapping("/updateArea")
    public ResultVO updateArea(Area area){
        return ResultVOUtil.success(areaService.updateArea(area));
    }
}
